import React from 'react';
import i from './index.module.css';
import WebSocMain from './layout';
import Login from './pages/login/index';
import Upcert from '@/pages/login/upCertificate';
import { getOEM } from '~/API/index';

import { HashRouter, Switch, Route } from 'react-router-dom';
import 'antd/dist/antd.min.css';
function App() {
  !localStorage.oem&&(localStorage.oem=JSON.stringify({"title":"创宇 WebSOC 网络资产安全检测系统","home":"北京知道创宇信息技术股份有限公司"}))
  !localStorage.product&&(localStorage.product=JSON.stringify({"status":"","is_trial":""}))
  const oem=async ()=>{
    const res = await getOEM().catch(()=>{return {}});
    const text_={
        title: res.data?.data?.product_fullname_cn||'创宇 WebSOC 网络资产安全检测系统',
        home:res.data?.data?.company_fullname_cn||'北京知道创宇信息技术股份有限公司'
    }
   localStorage.oem=JSON.stringify(text_)
    const text=JSON.parse(localStorage.oem)
    document.title = res.data?.data?.product_fullname_cn||'创宇 WebSOC 网络资产安全检测系统'
  }
  React.useMemo(()=>{
    oem()
  },[])
  React.useEffect(()=>{
    let link = document.querySelector("link[rel*='icon']") || document.createElement("link");
    link.type = "image/x-icon";
    link.rel = "shortcut icon";
    link.href ="/static/title_logo.svg?ranparam="+Math.random();  //icon图标
    document.getElementsByTagName("head")[0].appendChild(link);
  },[])
  return (
    <HashRouter>
      <Switch>
        <Route exact path="/login" component={Login} />
        <Route exact path="/upcert:id" component={Upcert} />
        <Route
          exact
          path="*"
          render={() => (
            <div className={i.App}>
              <WebSocMain />
            </div>
          )}
        />
      </Switch>
    </HashRouter>
  );
}

export default App;
